<template>
  <div style="margin: 20px">
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="ID" width="95">
        <template slot-scope="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column
        label="IP地址"
        width="200"
        prop="ip"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column label="归属地" prop="address" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="updatetime" label="时间" width="200">
        <template slot-scope="{ row }">
          <span>{{ new Date(row.updatetime).toLocaleString() }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
      @pagination="init"
    />
  </div>
</template>
<script>
import { VISITOR_LIST } from "@/api/blog";
import Pagination from "@/components/Pagination";
export default {
  name: "BlogVisitors",
  data() {
    return {
      list: [],
      listLoading: false,
      total: 0,
      listQuery: {
        page: 1,
        limit: 10,
      },
    };
  },
  created() {
    this.init();
  },
  components: {
    Pagination,
  },
  methods: {
    init() {
      this.listLoading = true;
      VISITOR_LIST(this.listQuery).then((res) => {
        console.log("访客列表=>>", res);
        this.list = res.data;
        this.total = res.total;
        this.listLoading = false;
      });
    },
  },
};
</script>
<style lang='scss' scoped>
</style>